import React, { Component } from "react";
// 1.0 导入prop-types
import ptype from "prop-types";

class PropTypesChcek extends Component {
  state = {};
  render() {
    return (
      <div>
        <CheckChild colors={19}></CheckChild>
      </div>
    );
  }
}

export default PropTypesChcek;

class CheckChild extends Component {
  state = {};
  render() {
    return (
      <div>
        {this.props.colors.map((item) => (
          <span>{item}</span>
        ))}
      </div>
    );
  }
}

// 2.0 给CheckChild 添加props属性合法性约束
CheckChild.propTypes = {
  colors: ptype.array,
};
